#ifndef LOG_H
#define LOG_H


#include "filestream.h"
#include <wchar.h>

#define LOG_MSG_DEBUG       5
#define LOG_MSG_INFO        4
#define LOG_MSG_WARNING     3
#define LOG_MSG_ERROR       2
#define LOG_MSG_CRITICAL    1


class Logger;

/**
* A static wrapper class for the Logger
*/
class Log
{
	public:

        
		/**
		* Initializes the log class
		*
		* @param logger the logger used
		*/
		static void init(Logger* logger);

		/**
		* Uninitializes the log class
		*
		* @param logger the logger used
		*/
		static void uninit();

		/**
		* Log an error message
		*
		* @param fmt format of the message
		* @param ... arguments
		*/
		static void msgError(const char* fmt, ...);
		static void msgErrorPID(String Pid, const char* fmt, ...);				// CGC 16/11/2010: PID in log (CSN-3067)

		/**
		* Log a warning message
		*
		* @param fmt format of the message
		* @param ... arguments
		*/
		static void msgWarning(const char* fmt, ...);
		static void msgWarningPID(String Pid, const char* fmt, ...);			// CGC 16/11/2010: PID in log (CSN-3067)

		/**
		* Log a information message
		*
		* @param fmt format of the message
		* @param ... arguments
		*/
		static void msgInformation(const char* fmt, ...);
		static void msgInformationPID(String Pid, const char* fmt, ...);		// CGC 16/11/2010: PID in log (CSN-3067)

		/**
		* Log an error message
		*
		* @param fmt format of the message
		* @param ... arguments
		*/
		static void msgError(const wchar_t* fmt, ...);
		static void msgErrorPID(String Pid, const wchar_t* fmt, ...);		// CGC 16/11/2010: PID in log (CSN-3067)

		/**
		* Log a warning message
		*
		* @param fmt format of the message
		* @param ... arguments
		*/
		static void msgWarning(const wchar_t* fmt, ...);
		static void msgWarningPID(String Pid, const wchar_t* fmt, ...);		// CGC 16/11/2010: PID in log (CSN-3067)

		/**
		* Log a information message
		*
		* @param fmt format of the message
		* @param ... arguments
		*/
		static void msgInformation(const wchar_t* fmt, ...);
		static void msgInformationPID(String Pid, const wchar_t* fmt, ...);	// CGC 16/11/2010: PID in log (CSN-3067)

		/**
		* Log the number of users connected
		*
		* @param Users number of users connected
		*/
		static void numUsers(int32 Users,String strAppName);

		/**
		* Log a stopping checkpoint
		*/
		static void stoppingCheckpoint();

		static void msgStart();

        /** 20091123 RPF 
		* Log an message 
		* @level Level of the message
		* @param szfmt message
		* 
		*/
        //(UNICODE)
		static void msg(int32 level, const wchar_t* szfmt,...);
        //(ANSI)
        static void msg(int32 level, const char* szfmt,...);

		// CGC: new log in text file
		static void LogEventTextFile(int32 level,  const char* fmt, va_list args);
		static void LogEventTextFile(String PID, int32 level,  const char* fmt, va_list args);		// CGC 16/11/2010: PID in log
		static void LogEventTextFile(int32 level,  const wchar_t* fmt, va_list args);
		static void LogEventTextFile(String PID, int32 level,  const wchar_t* fmt, va_list args);	// CGC 16/11/2010: PID in log
       
	protected:
		static Logger* logger;		/**< logger used to log */ 
	private:
		// CGC: new log in text file
		static pFileStream			fs;
		static String				strAppName;
		static String				strFullPathAppName;
		static PCRITICAL_SECTION	iolog;
		

};

#endif
